	//
//  TDHttpEngine.m
//  TFB
//
//  Created by Nothing on 15/3/20.
//  Copyright (c) 2015年 TD. All rights reserved.
//

#import "TDHttpEngine.h"
#import "JMGTMBase64.h"
#import "NSString+MD5.h"
#import "NSString+MD5.h"
#import "JSONKit.h"
#import "TDProvince.h"
#import "TDDynamicImg.h"

//#define HOST @"http://59.56.73.144/mpcctp/"
//#define HOST @"http://192.168.0.232:8090/mpcctp/"     //测试
//#define HOST @"http://192.168.0.113:8080/mpcctp/"     //郑强
//#define HOST @"http://192.168.0.59:8080/mpcctp/"      //朱跻
//#define HOST @"http://192.168.0.103:8080/mpcctp/"     //李淼
//#define HOST @"http://192.168.0.128:8080/mpcctp/"     //单蓓艺
//#define HOST @"http://210.22.153.30:8098/mpcctp"
#define SUFFIX @".json"

#define ENCODE_KEY  @"11111111111111110123456789ABCDEF"

#ifdef JIMIPAY
#define REGIST              @"IN0005"    //注册
#define UPBANKCARD          @"IN0002"    //银行卡绑定与修改
#define PARORDER            @"IN0008"    //商品订单(下单)
#define CERTIFICATION       @"IN0006"    //商户实名认证
#else
#define REGIST              @"SY0002"    //注册
#define UPBANKCARD          @"SY0008"    //银行卡绑定与修改
#define PARORDER            @"OD0001"    //商品订单(下单)
#define CERTIFICATION       @"SY0007"    //商户实名认证
#endif

#define GETMSGCODE          @"SY0001"    //发送验证码
//#define REGIST              @"SY0002"    //注册
#define LOGIN               @"SY0003"    //登录
#define VERIFYMSGCODE       @"SY0013"    //验证码验证
#define GETCUSTINF          @"SY0004"    //商户信息查询
#define UPDATAPWD           @"SY0005"    //商户密码修改与找回
#define LOGOUT              @"SY0014"    //退出登录
//#define CERTIFICATION       @"SY0007"    //商户实名认证
//#define UPBANKCARD          @"SY0008"    //银行卡绑定与修改
#define CHECKVERSION        @"SY0009"    //版本检测与更新
#define DYNAMICIMG          @"SY0010"    //首页轮播图获取
#define NOTICE              @"SY0011"    //公告查询
#define GETPROVINCE         @"SY0012"    //获取省列表
#define GETCITY             @"SY0014"    //获取市列表
#define GETAREA             @"SY0015"    //获取地区列表
#define GETCARDINFO         @"SY0015"    //获取银行卡信息
#define GETBANKNAME         @"SY0016"    //获取支持银行卡名称
#define GETLATESTNOTICE     @"SY0017"    //最新公告查询
#define GETMYMERCHANT       @"SY0018"    //我的商户
#define GET_FAQ             @"SY0019"    //常见问题
#define GET_MONEY_INFO      @"SY0022"    //资金账号信息
#define GET_MY_BENIFITS     @"PR0001"    //我的收益
#define GET_MY_TIXIAN       @"PR0003"    //我的提现
#define DRAW_MONEY          @"PY0004"    //提现
#define REALNAME_CERT       @"IN0009"    //实名认证（新）

#define GETMIYAO            @"SG0002"    //获取秘钥

#define CARDINQUIRYBALANCE  @"PY1001"    //银行卡余额查询


#define TERMBIND            @"TE0001"    //终端绑定
#define GETTERMLIST         @"TE0002"    //终端列表查询
//#define PARORDER            @"OD0001"    //商品订单(下单)
#define PAYMENT             @"PY0001"    //支付
#define QUICK_WITHDRAW      @"OD0003"    //快速取款

#define GETTRANSERIALLIST   @"TR0001"    //交易记录
#define GETTRANDETAIL       @"OD0002"    //交易记录详情


#define RSPCOD_SUCCEED      @"000000"   //成功响应码
#define RSPCOD_TIMEOUE      @"888888"   //在线超时，要求重新登录
#define RSPCOD_OTHERLOGIN   @"888889"   //已在其他设备登录
#define RSPCOD_UNLOGIN      @"900001"   //客户端未登录

//宏定义AlertView
#define SHOW_ALERT(_message_) UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:_message_ delegate:nil cancelButtonTitle:@"我知道啦！" otherButtonTitles: nil]; \
[alert show];

@interface TDHttpEngine ()


/**
 *  传入公共参数
 *
 *  @param sender 原来参数字典
 */
+ (void)addFixedValueWithDic:(id)sender;

/**
 *  把需要的参数转换为后台可以读得数据类型
 *
 *  @param sender 需要传得参数
 *
 *  @return 后台可以读的数据
 */
+ (NSDictionary *)jsonWithDic:(id)sender;

/**
 *  简单请求、只需要请求成功失败等一些简单参数 的基请求
 *
 *  @param params    传参数据
 *  @param tradeCode 交易码
 *  @param complete  block回传
 */
+ (void)requestWithParams:(NSDictionary *)params tradeCode:(NSString *)tradeCode complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete;

/**
 *  需要回传一下数组数据
 *
 *  @param params    传参数据
 *  @param tradeCode 交易码
 *  @param complete  block回传
 */
+ (void)requestSomeArrayWithParams:(NSDictionary *)params tradeCode:(NSString *)tradeCode complete:(void(^)(BOOL succeed, NSString *msg, NSArray *someArray))complete;

@end


@implementation TDHttpEngine


//初始化网络请求引擎
+ (instancetype)shareHttpEngine
{
    
    static TDHttpEngine *httpEngine;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        httpEngine = [[self alloc] init];
    });
    return httpEngine;
}


/**
 *  把需要的参数转换为后台可以读得数据类型
 *
 *  @param sender 需要传得参数
 *
 *  @return 后台可以读的数据
 */
+ (NSDictionary *)jsonWithDic:(id)sender
{
    //
    //    [sender setObject:@"13273901442" forKey:@"custMobile"];
    //    [sender setObject:@"15040300000025" forKey:@"custId"];
    
    //固定参数
    [self addFixedValueWithDic:sender];
    
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
    
    NSMutableDictionary *jsonDic = [[NSMutableDictionary alloc] init];
    [jsonDic setObject:sender forKey:@"REQ_BODY"];
    
    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:sender options:NSJSONWritingPrettyPrinted error:nil];
    NSString *jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    jsonStr = [[jsonStr stringByReplacingOccurrencesOfString:@"\n" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
    jsonStr = [jsonStr stringByReplacingOccurrencesOfString:@"\\/" withString:@"/"];
    
    
    NSString *md5Str = [[NSString stringWithFormat:@"%@%@", jsonStr, ENCODE_KEY] MD5];//[[sender JSONString] MD5];
    
    
    NSMutableDictionary *headDic = [[NSMutableDictionary alloc] init];
    [headDic setObject:md5Str forKey:@"SIGN"];
    [jsonDic setObject:headDic forKey:@"REQ_HEAD"];
    
    jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];
    jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    jsonStr = [[jsonStr stringByReplacingOccurrencesOfString:@"\n" withString:@""] stringByReplacingOccurrencesOfString:@" " withString:@""];
    [dataDic setObject:jsonStr forKey:@"REQ_MESSAGE"];
    NSLog(@"请求报文：%@", jsonDic);
    return dataDic;
    
}

+ (void)addFixedValueWithDic:(id)sender
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateStr = [formatter stringFromDate:[NSDate date]];
    
    NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
    [timeFormatter setDateFormat:@"HH:mm:ss"];
    NSString *timeStr = [timeFormatter stringFromDate:[NSDate date]];
    
    NSString *udidStr = [UIDevice currentDevice].identifierForVendor.UUIDString;
    
    [sender setObject:@"2" forKey:@"sysType"]; //iOS
    [sender setObject:[[UIDevice currentDevice] systemVersion] forKey:@"sysVersion"];//系统版本
    [sender setObject:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] forKey:@"appVersion"];//APP版本
    [sender setObject:udidStr forKey:@"sysTerNo"];//设备uuid
    [sender setObject:dateStr forKey:@"txnDate"];
    [sender setObject:timeStr forKey:@"txnTime"];
    [sender setObject:CLIENT_ID forKey:@"clientId"];
    
    NSString *token = [[NSUserDefaults standardUserDefaults] objectForKey:CUST_TOKEN];
    if (token.length) {
        [sender setObject:token forKey:@"token"];
    }
}

/**
 *  简单请求、只需要请求成功失败等一些简单参数 的基请求
 *
 *  @param params    传参数据
 *  @param tradeCode 交易码
 *  @param complete  block回传
 */
+ (void)requestWithParams:(NSDictionary *)params tradeCode:(NSString *)tradeCode complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, tradeCode, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:params] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"%@", weakOperation.responseString);
        
        NSDictionary *diction = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
            if (complete) {
                
                if ([tradeCode isEqualToString:LOGIN]) {
                    NSString *custId = [[diction objectForKey:@"REP_BODY"] objectForKey:@"custId"];
                    NSString *custMobile = [[diction objectForKey:@"REP_BODY"] objectForKey:@"custLogin"];
                    NSString *token = [[diction objectForKey:@"REP_BODY"] objectForKey:@"token"];
                    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
                    [userDefaults setObject:custId forKey:CUST_ID];
                    [userDefaults setObject:custMobile forKey:CUST_MOBILE];
                    [userDefaults setObject:token forKey:CUST_TOKEN];
                    [userDefaults synchronize];
                }
                
                complete(YES, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"]);
            }
        }
        else
        {
            if (complete) {
                complete(NO, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"]);
                //SHOW_ALERT([[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"]);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        NSLog(@"error---> %@\r errmasage--->%@", error, [error localizedDescription]);
        if (complete) {
            complete(NO, [error localizedDescription], @"");
        }
    }];
    [networkEngine enqueueOperation:operation];
}


/**
 *  需要回传一些数组数据的基请求   这种请求挺多的，方法里面一直判断也挺麻烦、暂时不用
 *
 *  @param params    传参数据
 *  @param tradeCode 交易码
 *  @param complete  block回传
 */
+ (void)requestDataWithParams:(NSDictionary *)params tradeCode:(NSString *)tradeCode complete:(void(^)(BOOL succeed, NSString *msg, id responseObject))complete
{
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, tradeCode, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:params] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"q请求成功");
        
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        NSString *code = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"];
        NSString *msg = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"];
        NSDictionary *rep_body = [dictionary objectForKey:@"REP_BODY"];
        
        if (complete) {
            if ([code isEqualToString:@"000000"]) {
                complete(YES, msg, rep_body);
            } else{
                complete(NO, msg, rep_body);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        if (complete) {
            complete(NO, @"网络异常", nil);
        }
    }];
    [networkEngine enqueueOperation:operation];
    
}

/**
 *  需要回传一些数组数据的基请求   这种请求挺多的，方法里面一直判断也挺麻烦、暂时不用
 *
 *  @param params    传参数据
 *  @param tradeCode 交易码
 *  @param complete  block回传
 */
+ (void)requestSomeArrayWithParams:(NSDictionary *)params tradeCode:(NSString *)tradeCode complete:(void(^)(BOOL succeed, NSString *msg, NSArray *someArray))complete
{
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, tradeCode, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:params] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"q请求成功");
        
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        NSString *msg = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"];
        NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:0];
        if ([[[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
            if ([tradeCode isEqualToString:DYNAMICIMG]) {
                NSLog(@"轮播图数据");
                NSArray *dataArray = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"imgList"];
                for (int i = 0; i < dataArray.count; i ++) {
                    TDDynamicImg *dynamicImg = [[TDDynamicImg alloc] initWithDictionary:dataArray[i]];
                    [tempArray addObject:dynamicImg];
                }
                if (complete) {
                    complete(YES, msg, tempArray);
                }
                
            }
            if ([tradeCode isEqualToString:GETPROVINCE]) {
                NSLog(@"省份数据列表");
                NSArray *dataArray = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"province"];
                for (int i = 0; i < dataArray.count; i ++) {
                    TDProvince *province = [[TDProvince alloc] initWithDictionary:dataArray[i]];
                    [tempArray addObject:province];
                }
                if (complete) {
                    complete(YES, msg, tempArray);
                }
            }
        }
        else{
            if (complete) {
                complete(NO, msg, nil);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        if (complete) {
            complete(NO, @"网络异常", nil);
        }
    }];
    [networkEngine enqueueOperation:operation];
}


/**
 *  发送验证码
 *
 *  @param custMobile 手机号
 *  @param codeType   验证码类型
 *  @param complete   block回传
 */
+ (void)requestForGetMsgCodeWithCustMobile:(NSString *)custMobile codeType:(NSString *)codeType complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custMobile, codeType] forKeys:@[@"custMobile", @"codeType"]];
    
    //    [self requestWithParams:dataDic tradeCode:GETMSGCODE complete:^(BOOL succeed, NSString *msg) {
    //        if (complete) {
    //            complete(succeed, msg);
    //        }
    //    }];
    
    [self requestWithParams:dataDic tradeCode:GETMSGCODE complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
    
    /*
     MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
     NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, GETMSGCODE, SUFFIX];
     MKNetworkOperation *operation = [networkEngine operationWithURLString:url params:[self jsonWithDic:dataDic] httpMethod:@"POST"];
     __weak MKNetworkOperation *weakOperation = operation;
     [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
     NSLog(@"%@", weakOperation.responseString);
     
     NSDictionary *diction = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
     if ([[[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
     if (complete) {
     complete(YES, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"]);
     }
     }
     else
     {
     if (complete) {
     complete(NO, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"]);
     //SHOW_ALERT([[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"]);
     }
     }
     
     } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
     NSLog(@"error---> %@\r errmasage--->%@", error, [error localizedDescription]);
     if (complete) {
     complete(NO, @"网络异常");
     //            SHOW_ALERT(@"网络异常");
     }
     }];
     [networkEngine enqueueOperation:operation];
     */
}

/**
 *  验证验证码
 *
 *  @param custMobile 手机号
 *  @param codeType   验证码类型
 *  @param msgCode    验证码
 *  @param isForgetPwd 是否是找回密码
 *  @param complete   block回传
 */
+ (void)requestForVerifyMsgCodeWithCustMobile:(NSString *)custMobile codeType:(NSString *)codeType msgCode:(NSString *)msgCode isForgetPwd:(BOOL)isForgetPwd complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custMobile, codeType, msgCode] forKeys:@[@"custMobile", @"codeType", @"msgCode"]];
    
    if (isForgetPwd) {
        [dataDic setObject:@"0" forKey:@"opType"];
    }
    
    [self requestWithParams:dataDic tradeCode:VERIFYMSGCODE complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  注册
 *
 *  @param custMobile      手机号
 *  @param custPwd         登录密码
 *  @param complete        block回传
 */

+ (void)requestForRegistWithCustMobile:(NSString *)custMobile custPwd:(NSString *)custPwd complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custMobile, custPwd] forKeys:@[@"custMobile", @"custPwd"]];
    
    if ([APPNAME isEqualToString:@"吉米支付"]) {
        dataDic = [NSMutableDictionary dictionaryWithObjects:@[custMobile, custPwd, @"16012300003218"] forKeys:@[@"custMobile", @"custPwd", @"referrer"]];
    }
    
    [self requestWithParams:dataDic tradeCode:REGIST complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}

/**
 *  登录
 *
 *  @param CustMobile 手机号
 *  @param custPwd    登录密码
 *  @param complete   block回传
 */
+ (void)requestForLoginWithCustMobile:(NSString *)custMobile custPwd:(NSString *)custPwd complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custMobile, custPwd] forKeys:@[@"custMobile", @"custPwd"]];
    
    [self requestWithParams:dataDic tradeCode:LOGIN complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  退出登录
 *
 *  @param complete   block回传
 */
+ (void)requestForLoginoutWithCustMobile:(NSString *)custMobile custId:(NSString *)custId complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestWithParams:dataDic tradeCode:LOGOUT complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  获取首页轮播图
 *
 *  @param complete   block回传
 */
+ (void)requestForIndexPageBannerSourceWithCustMobile:(NSString *)custMobile custId:(NSString *)custId complete:(void(^)(BOOL succeed, NSString *msg, id req_body))complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestDataWithParams:dataDic tradeCode:DYNAMICIMG complete:^(BOOL succeed, NSString *msg, id responseObject) {
        if (complete) {
            complete(succeed, msg, responseObject);
        }
    }];
}

/**
 *  商户信息查询
 *
 *  @param custMobile 手机号
 *  @param custId     商户id
 *  @param complete   block回传
 */
+ (void)requestForGetCustInfWithCustMobile:(NSString *)custMobile custId:(NSString *)custId complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod, TDUser *user))complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *urlStr = [NSString stringWithFormat:@"%@%@%@", HOST, GETCUSTINF, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:urlStr params:[self jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"返回数据：%@", weakOperation.responseString);
        NSDictionary *dataDic = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
            if (complete) {
                TDUser *user = [TDUser defaultUser];
                user.custId = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"custId"];
                user.custLogin = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"custLogin"];
                user.custStatus = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"custStatus"];
                user.cardNum = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"cardNum"];
                user.termNum = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"termNum"];
                user.custName = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"custName"];
                user.cardBundingStatus = [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"cardBundingStatus"];
                
                complete(YES, [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], user);
            }
        }
        else
        {
            if (complete) {
                complete(NO, [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], nil);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        NSLog(@"网络异常");
        if (complete) {
            complete(NO, [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], nil);
        }
    }];
    [networkEngine enqueueOperation:operation];
}

/**
 *  获取银行卡信息
 *
 *  @param custMobile 手机号
 *  @param custId     商户id
 *  @param complete   block回传
 */
+ (void)requestFor_GETCARDINFO_WithCustMobile:(NSString *)custMobile
                                       custId:(NSString *)custId
                                     complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETCARDINFO complete:complete];
}

/**
 *  商户密码修改与找回
 *
 *  @param pwdType    修改的密码类型	N		密码类型：1-登录密码；2-支付密码
 *  @param updateType 修改方式	N		1：根据原密码修改；2：根据短信验证码找回
 *  @param value      短信验证码或原始密码	N
 *  @param newPwd     新密码	N
 *  @param custMobile 手机号	N
 *  @param complete   block回传
 */
+ (void)requestForUpdatePwdWithPwdType:(NSString *)pwdType updateType:(NSString *)updateType value:(NSString *)value newPwd:(NSString *)newPwd custMobile:(NSString *)custMobile complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[pwdType, updateType, value, newPwd, custMobile] forKeys:@[@"pwdType", @"updateType", @"value", @"newPwd", @"custMobile"]];
    
    [self requestWithParams:dataDic tradeCode:UPDATAPWD complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  商户实名认证
 *
 *  @param cardHandheld 手持身份证照片	N
 *  @param cardFront    身份证正面照片	N
 *  @param cardBack     身份证背面照片	N
 *  @param custId       商户编号	N
 *  @param complete     block回传
 */
+ (void)requestForCertificationWithCardHandheld:(NSString *)cardHandheld
                                      cardFront:(NSString *)cardFront
                                       cardBack:(NSString *)cardBack
                                     activeCode:(NSString *)activeCode
                                         custId:(NSString *)custId
                                     custMobile:(NSString *)custMobile
                                       custName:(NSString *)custName
                                certificateType:(NSString *)certificateType
                                  certificateNo:(NSString *)certificateNo
                                     provinceId:(NSString *)provinceId
                                         cityId:(NSString *)cityId
                                         areaId:(NSString *)areaId
                                         payPwd:(NSString *)payPwd
                                       complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = nil;
    
    if (SHOW_WEIZHUAN == 1) {
        dataDic = [NSMutableDictionary dictionaryWithObjects:@[cardHandheld, cardFront, cardBack, custId, custMobile, custName, certificateType, certificateNo, provinceId, cityId, areaId] forKeys:@[@"cardHandheld", @"cardFront", @"cardBack", @"custId", @"custMobile", @"custName", @"certificateType", @"certificateNo", @"provinceId", @"cityId", @"regionId"]];
    } else {
        dataDic = [NSMutableDictionary dictionaryWithObjects:@[cardHandheld, cardFront, cardBack, activeCode, custId, custMobile, custName, certificateType, certificateNo, provinceId, cityId, areaId] forKeys:@[@"cardHandheld", @"cardFront", @"cardBack", @"activeCode", @"custId", @"custMobile", @"custName", @"certificateType", @"certificateNo", @"provinceId", @"cityId", @"regionId"]];
    }
    
    if (payPwd.length) {
        [dataDic setObject:payPwd forKey:@"payPwd"];
    }
    
    [self requestWithParams:dataDic tradeCode:CERTIFICATION complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  银行卡修改与绑定     --后台修改中
 *
 *  @param operType   operType	操作类型	N   1-银行卡绑定；2-银行卡信息修改；3-设为默认银行卡，4-解绑(删除)
 *  @param oldCardNo  oldCardNo	原银行卡号	Y	当操作类型为银行卡号修改时，该字段必须为改变前的银行卡号
 *  @param cardNo     cardNo	银行卡号	N		需要绑定的银行卡号或需要变更的新卡号
 *  @param cardFront  cardFront	银行卡正面照片	Y		商户绑定或更改的银行卡正面照片
 *  @param cardBack   cardFront	银行卡正面照片	Y		商户绑定或更改的银行卡正面照片
 *  @param provinceId provinceId	银行卡所属省份Id	Y		省份来源：服务器省市列表获取接口
 *  @param cityId     cityId	银行卡开户城市Id	Y		城市来源：服务器省市列表获取接口
 *  @param cnapsCode  cnapsCode	联行号	Y		当用户可以选择到对应的联行号时上传
 *  @param complete     block回传
 */
+ (void)requestForUpBankCardWithCustId:(NSString *)custId
                            custMobile:(NSString *)custMobile
                              OperType:(NSString *)operType
                             oldCardNo:(NSString *)oldCardNo    //*
                                cardNo:(NSString *)cardNo
                              cardName:(NSString *)cardName
                             cardFront:(NSString *)cardFront
                              cardBack:(NSString *)cardBack
                            provinceId:(NSString *)provinceId
                                cityId:(NSString *)cityId
                                areaId:(NSString *)areaId
                              bankcode:(NSString *)bankcode
                             cnapsCode:(NSString *)cnapsCode    //*
                              complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete;
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile, operType, cardNo, cardFront, cardBack, provinceId, cityId, areaId, bankcode, cardName] forKeys:@[@"custId", @"custMobile", @"operType", @"cardNo", @"cardFront", @"cardBack", @"provinceId", @"cityId", @"regionId", @"bankcode", @"bankType"]];
    
    if (oldCardNo.length) {
        [dataDic setObject:oldCardNo forKey:@"oldCardNo"];
    }
    
    if (cnapsCode.length) {
        [dataDic setObject:cnapsCode forKey:@"cnapsCode"];
    }
    
    [self requestWithParams:dataDic tradeCode:UPBANKCARD complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  获取省列表
 *
 *  @param custId       商户id    Y
 *  @param complete     block回传
 */
+ (void)requestForGetProvinceWithCustId:(NSString *)custId custMobile:(NSString *)custMobile complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod, NSArray *array))complete;
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    //    [self requestSomeArrayWithParams:dataDic tradeCode:GETPROVINCE complete:^(BOOL succeed, NSString *msg, NSArray *someArray) {
    //        complete(succeed, msg, someArray);
    //    }];
    MKNetworkEngine *netWorkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, GETPROVINCE, SUFFIX];
    MKNetworkOperation *operation = [netWorkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString:RSPCOD_SUCCEED])
        {
            NSArray *dataArray = [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"province"];
            NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:0];
            for (int i = 0; i < dataArray.count; i++) {
                TDProvince *province = [[TDProvince alloc] initWithDictionary:dataArray[i]];
                [tempArray addObject:province];
            }
            if (complete) {
                complete(YES, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], tempArray);
            }
            
        }
        else{
            if (complete) {
                complete(NO, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], nil);
            }
        }
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        if (complete) {
            complete(NO, @"网络异常", @"", nil);
        }
    }];
    
    [netWorkEngine enqueueOperation:operation];
}

/**
 *  绑定终端
 *
 *  @param custId   商户id
 *  @param termNo   终端序列号
 *  @param complete block回传
 */
+ (void)requestForBDZDWithCustId:(NSString *)custId custMobile:(NSString *)custMobile termNo:(NSString *)termNo complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile,termNo] forKeys:@[@"custId", @"custMobile", @"termNo"]];
    
    [self requestWithParams:dataDic tradeCode:TERMBIND complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
}


/**
 *  获取轮播图
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestForDynamicImgWithCustId:(NSString *)custId custMobile:(NSString *)custMobile complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod, NSArray *imageArray))complete
{
    
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    //    [self requestSomeArrayWithParams:dataDic tradeCode:DYNAMICIMG complete:^(BOOL succeed, NSString *msg, NSArray *someArray) {
    //        if (complete) {
    //            complete(succeed, msg, someArray);
    //        }
    //    }];
    MKNetworkEngine *netWorkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, DYNAMICIMG, SUFFIX];
    MKNetworkOperation *operation = [netWorkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString:RSPCOD_SUCCEED])
        {
            NSArray *dataArray = [[dictionary objectForKey:@"REQ_BODY"] objectForKey:@"imgList"];
            NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:0];
            for (int i = 0; i < dataArray.count; i ++) {
                TDDynamicImg *dynamicImg = [[TDDynamicImg alloc] initWithDictionary:dataArray[i]];
                [tempArray addObject:dynamicImg];
            }
            if (complete) {
                complete(YES, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], tempArray);
            }
            
        }
        else{
            if (complete) {
                complete(NO, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], nil);
            }
        }
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        if (complete) {
            complete(NO, @"网络异常", @"", nil);
        }
    }];
    
}


/**
 *  商品订单(下单)
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param prdordType 订单类型	N	01收款  02商品 (便民)
 *  @param bizType    子订单类型	Y	当prdordType取值02，该字段取值：01 手机充值 02 …
 *  @param prdordAmt  订单金额
 *  @param complete   block回传
 */
+ (void)requestForPrdOrderWithCustId:(NSString *)custId custMobile:(NSString *)custMobile prdordType:(NSString *)prdordType bizType:(NSString *)bizType prdordAmt:(NSString *)prdordAmt complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod, NSDictionary *infoDic))complete;
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile, prdordType, bizType, prdordAmt] forKeys:@[@"custId", @"custMobile", @"prdordType", @"bizType", @"prdordAmt"]];
    
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, PARORDER, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"%@", weakOperation.responseString);
        
        NSDictionary *diction = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
            if (complete) {
                complete(YES, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], [diction objectForKey:@"REP_BODY"]);
            }
        }
        else
        {
            if (complete) {
                complete(NO, [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[diction objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], [diction objectForKey:@"REP_BODY"]);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        NSLog(@"error---> %@\r errmasage--->%@", error, [error localizedDescription]);
        if (complete) {
            complete(NO, @"网络异常", @"", nil);
        }
    }];
    [networkEngine enqueueOperation:operation];
    
}


/**
 *  获取终端列表
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestForGetTermListWithCustId:(NSString *)custId custMobile:(NSString *)custMobile complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod, NSArray *termArray))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    MKNetworkEngine *netWorkEngine = [[MKNetworkEngine alloc] init];
    NSString *url = [NSString stringWithFormat:@"%@%@%@", HOST, GETTERMLIST, SUFFIX];
    MKNetworkOperation *operation = [netWorkEngine operationWithURLString:url params:[TDHttpEngine jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        NSLog(@"shuju---%@", weakOperation.responseString);
        if ([[[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString:RSPCOD_SUCCEED])
        {
            NSArray *dataArray = [[dictionary objectForKey:@"REQ_BODY"] objectForKey:@"province"];
            NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:0];
            for (int i = 0; i < dataArray.count; i++) {
                
            }
            if (complete) {
                complete(YES, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], tempArray);
            }
            
        }
        else{
            if (complete) {
                complete(NO, [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [[dictionary objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"], nil);
            }
        }
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        if (complete) {
            complete(NO, @"网络异常", @"", nil);
        }
    }];
    [netWorkEngine enqueueOperation:operation];
}


+ (void)requestForGetMiYaoWithCustMobile:(NSString *)custMobile termNo:(NSString *)termNo termType:(NSString *)termType custId:(NSString *)custId complete:(void(^)(BOOL succeed, NSString *msg, NSDictionary *diction))complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, termNo, termType] forKeys:@[@"custId", @"custMobile", @"termNo", @"termType"]];
    MKNetworkEngine *networkEngine = [[MKNetworkEngine alloc] init];
    NSString *urlStr = [NSString stringWithFormat:@"%@%@%@", HOST, GETMIYAO, SUFFIX];
    MKNetworkOperation *operation = [networkEngine operationWithURLString:urlStr params:[self jsonWithDic:dataDic] httpMethod:@"POST"];
    __weak MKNetworkOperation *weakOperation = operation;
    [weakOperation addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSLog(@"返回数据：%@", weakOperation.responseString);
        NSDictionary *dataDic = [NSJSONSerialization JSONObjectWithData:weakOperation.responseData options:NSJSONReadingMutableContainers error:nil];
        if ([[[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPCOD"] isEqualToString: RSPCOD_SUCCEED]) {
            if (complete) {
                complete(YES, [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [dataDic objectForKey:@"REP_BODY"]);
            }
            
        }
        else
        {
            if (complete) {
                complete(NO, [[dataDic objectForKey:@"REP_BODY"] objectForKey:@"RSPMSG"], [dataDic objectForKey:@"REP_BODY"]);
            }
        }
        
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        NSLog(@"网络异常");
    }];
    [networkEngine enqueueOperation:operation];
}


+ (void)requestForPayWithCustId:(NSString *)custId custMobile:(NSString *)custMobile prdordNo:(NSString *)prdordNo payType:(NSString *)payType rate:(NSString *)rate termNo:(NSString *)termNo termType:(NSString *)termType payAmt:(NSString *)payAmt track:(NSString *)track pinblk:(NSString *)pinblk random:(NSString *)random mediaType:(NSString *)mediaType period:(NSString *)period icdata:(NSString *)icdata crdnum:(NSString *)crdnum mac:(NSString *)mac complete:(void(^)(BOOL succeed, NSString *msg, NSString *cod))complete
{
    NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithObjects:@[custId, custMobile, prdordNo, payType, rate, termNo, termType, payAmt, track, pinblk, random, mediaType, period, icdata, crdnum, mac] forKeys:@[@"custId", @"custMobile", @"prdordNo", @"payType", @"rate", @"termNo", @"termType", @"payAmt", @"track", @"pinblk", @"random", @"mediaType", @"period", @"icdata", @"crdnum", @"mac"]];
    [self requestWithParams:dataDic tradeCode:PAYMENT complete:^(BOOL succeed, NSString *msg, NSString *cod) {
        if (complete) {
            complete(succeed, msg, cod);
        }
    }];
    
}


#pragma mark - 交易
/**
 *  交易记录
 *
 *  @param custId     商户id
 *  @param start      开始取记录的行号
 *  @param pageSize   要取出记录数
 *  @param complete   block回传
 */
+ (void)requestFor_GETTRANSERIALLIST_WithCustId:(NSString *)custId
                                     custMobile:(NSString *)custMobile
                                          start:(NSUInteger)start
                                       pageSize:(NSUInteger)pageSize
                                       complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, [NSString stringWithFormat:@"%lu", start], [NSString stringWithFormat:@"%lu", pageSize]] forKeys:@[@"custId", @"custMobile", @"start", @"pageSize"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETTRANSERIALLIST complete:complete];
}

/**
 *  交易记录详情
 *
 *  @param custId     商户id
 *  @param start      开始取记录的行号
 *  @param payordno   在交易记录查询中，有返回支付编号payordno
 */
+ (void)requestFor_GETTRANDETAIL_WithCustId:(NSString *)custId
                                 custMobile:(NSString *)custMobile
                                   payordno:(NSString *)payordno
                                   complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, payordno] forKeys:@[@"custId", @"custMobile", @"payordno"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETTRANDETAIL complete:complete];
}

/**
 *  商品订单（下单）
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param prdordType 商品类型 01百货商店 02 航空公司 03 大型景区售票
 *  @param prdordAmt  订单金额
 *  @param complete   block回传
 */
+ (void)requestFor_PARORDER_WithCustId:(NSString *)custId
                            custMobile:(NSString *)custMobile
                            prdordType:(NSString *)prdordType
                             prdordAmt:(NSString *)prdordAmt
                               payType:(NSString *)payType
                              complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, prdordType, prdordAmt, payType] forKeys:@[@"custId", @"custMobile", @"prdordType", @"prdordAmt", @"payType"]];
    
    [self requestDataWithParams:dataDic tradeCode:PARORDER complete:complete];
}

/**
 *  公告查询
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param start      开始取记录的行号
 *  @param pageSize   要取出记录数
 *  @param complete   block回传
 */
+ (void)requestFor_NOTICE_WithCustId:(NSString *)custId
                          custMobile:(NSString *)custMobile
                               start:(NSUInteger)start
                            pageSize:(NSUInteger)pageSize
                              lastId:(NSString *)lastId
                            complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, [NSString stringWithFormat:@"%lu", start], [NSString stringWithFormat:@"%lu", pageSize]] forKeys:@[@"custId", @"custMobile", @"start", @"pageSize"]];
    
    if (lastId.length) {
        [dataDic setObject:lastId forKey:@"lastId"];
    }
    
    [self requestDataWithParams:dataDic tradeCode:NOTICE complete:complete];
}

/**
 *  获取支持的银行名称列表
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestFor_GETBANKNAME_WithCustId:(NSString *)custId
                               custMobile:(NSString *)custMobile
                                 complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, @"YBBANKTYPE"] forKeys:@[@"custId", @"custMobile", @"code"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETBANKNAME complete:complete];
}

/**
 *  快速提款
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestFor_QUICK_WITHDRAW_WithCustId:(NSString *)custId
                                  custMobile:(NSString *)custMobile
                                    complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestDataWithParams:dataDic tradeCode:QUICK_WITHDRAW complete:complete];
}

/**
 *  最新公告查询
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestFor_GETLATESTNOTICE_WithCustId:(NSString *)custId
                                   custMobile:(NSString *)custMobile
                                       lastId:(NSString *)lastId
                                     complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, lastId] forKeys:@[@"custId", @"custMobile", @"lastId"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETLATESTNOTICE complete:complete];
}

/**
 *  我的商户
 *
 *  @param custId     商户id
 *  @param custMobile 手机号
 *  @param complete   block回传
 */
+ (void)requestFor_GETMYMERCHANT_WithCustId:(NSString *)custId
                                 custMobile:(NSString *)custMobile
                                   complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestDataWithParams:dataDic tradeCode:GETMYMERCHANT complete:complete];
}

/**
 *  监测更新
 *
 *  @param appVersion     版本
 *  @param appPlatform    平台
 *  @param complete   block回传
 */
+ (void)requestFor_CHECKVERSION_WithCustId:(NSString *)custId
                                custMobile:(NSString *)custMobile
                                appVersion:(NSString *)appVersion
                               appPlatform:(NSString *)appPlatform
                                  complete:(Req_Body_complete)complete
{
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, appVersion, appPlatform] forKeys:@[@"custId", @"custMobile", @"appVersion", @"appPlatform"]];
    
    [self requestDataWithParams:dataDic tradeCode:CHECKVERSION complete:complete];
}

/**
 *  常见问题
 *
 *  @param start      开始取记录的行号
 *  @param pageSize   要取出记录数
 *  @param complete   block回传
 */
+ (void)requestFor_GET_FAQ_WithCustId:(NSString *)custId
                           custMobile:(NSString *)custMobile
                                start:(NSUInteger)start
                             pageSize:(NSUInteger)pageSize
                             complete:(Req_Body_complete)complete {
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, [NSString stringWithFormat:@"%lu", start], [NSString stringWithFormat:@"%lu", pageSize]] forKeys:@[@"custId", @"custMobile", @"start", @"pageSize"]];
    
    [self requestDataWithParams:dataDic tradeCode:GET_FAQ complete:complete];
}

+ (void)requestFor_GET_MONEY_INFO_WithCustId:(NSString *)custId
                                  custMobile:(NSString *)custMobile
                                    complete:(Req_Body_complete)complete {
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile] forKeys:@[@"custId", @"custMobile"]];
    
    [self requestDataWithParams:dataDic tradeCode:GET_MONEY_INFO complete:complete];
}

+ (void)requestFor_GET_MY_BENIFITS_WithCustId:(NSString *)custId
                                   custMobile:(NSString *)custMobile
                                        start:(NSUInteger)start
                                     pageSize:(NSUInteger)pageSize
                                     complete:(Req_Body_complete)complete {
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, [NSString stringWithFormat:@"%lu", start], [NSString stringWithFormat:@"%lu", pageSize]] forKeys:@[@"custId", @"custMobile", @"start", @"pageSize"]];
    
    [self requestDataWithParams:dataDic tradeCode:GET_MY_BENIFITS complete:complete];
}

+ (void)requestFor_GET_MY_TIXIAN_WithCustId:(NSString *)custId
                                 custMobile:(NSString *)custMobile
                                      start:(NSUInteger)start
                                   pageSize:(NSUInteger)pageSize
                                   complete:(Req_Body_complete)complete {
    
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, [NSString stringWithFormat:@"%lu", start], [NSString stringWithFormat:@"%lu", pageSize]] forKeys:@[@"custId", @"custMobile", @"start", @"pageSize"]];
    
    [self requestDataWithParams:dataDic tradeCode:GET_MY_TIXIAN complete:complete];
}

+ (void)requestFor_DRAW_MONEY_WithCustId:(NSString *)custId
                              custMobile:(NSString *)custMobile
                                   txAmt:(NSString *)txAmt
                                complete:(Req_Body_complete)complete {
    
    NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] initWithObjects:@[custId, custMobile, txAmt] forKeys:@[@"custId", @"custMobile", @"txamt"]];
    
    [self requestDataWithParams:dataDic tradeCode:DRAW_MONEY complete:complete];
}

+ (void)requestFor_REALNAME_CERT_WithDic:(NSDictionary *)params
                                complete:(Req_Body_complete)complete {
    [self requestDataWithParams:params tradeCode:REALNAME_CERT complete:complete];
}

@end
